package kuwo

import (
	"api-go/serializer"
	"api-go/util"
)

// MV所需信息
type MV struct {
	Offset string `form:"offset"`
	Id     string `form:"id"`
	Limit  string `form:"limit"`
}

//获取MV列表
func (service *MV) MVList() *serializer.Response {

	if val := service.Offset; val != "" {
		service.Offset = val
	} else {
		service.Offset = "1"
	}

	if val := service.Limit; val != "" {
		service.Limit = val
	} else {
		service.Limit = "30"
	}

	url := "http://www.kuwo.cn/api/www/music/mvList?pid=236682871&httpsStatus=1&rn=" + service.Limit + "&pn=" + service.Offset

	res, err := util.KuwoGet(url)
	if err != nil {
		return err
	}
	return serializer.OkResponse(res)
}

//获取MV信息
func (service *MV) MVInfo() *serializer.Response {

	//此处Id实则为hash
	if val := service.Id; val != "" {
		service.Id = val
	} else {
		service.Id = "155515226"
	}

	url := "https://antiserver.kuwo.cn/anti.s?type=convert_url&format=mp4&response=url&rid=" + service.Id

	res, err := util.SGet(url)
	if err != nil {
		return err
	}
	return serializer.OkResponse(res)
}
